package com.leetcode;

import java.util.ArrayList;
import java.util.List;

/**
 * 933. 最近的请求次数
 * 使用List计数
 *
 * @author fy
 * @date 2022-05-09 20:55
 */
public class Solution933 {

    class RecentCounter {

        private List<Integer> list;

        public RecentCounter() {
            list = new ArrayList<>();
        }

        public int ping(int t) {
            int max = t;
            int min = t - 3000;
            list.add(t);
            int res = 0;
            for (Integer item : list) {
                if (item >= min && item <= max) {
                    res++;
                }
            }
            return res;
        }
    }

}
